<template>
  <div style="height:100%;overflow:auto;width:100%;">
    <div style="padding: 10px 16px 0; display: flex; align-items: center; ">
      <el-button size="mini" type="plain" @click="download" :disabled="batchFile.loading" :icon="batchFile.loading ? 'el-icon-loading' : 'el-icon-download'">{{ batchFile.loading ? '下载中....' : '下载' }}</el-button>
      <span class="download-all">下载全部</span>
      <div />
    </div>
    <!-- 图片列表展示 -->
    <div class="img-list-wrap" title="点击放大查看" v-show="room.records.length">
      <div class="img-list-item" v-for="item in room.records" :key="item">
        <div class="img-wrap">
          <img preview="0" :src="item.file" alt />
          <p class="name-info">{{ item.name }}</p>
          <p class="date-info">{{ item.time }}</p>
        </div>
        <div class="video-path">{{ item.file }}</div>
      </div>
    </div>
    <!-- 无数据提示 -->
    <div class="no-data" v-show="!room.records.length">暂无数据</div>
    <el-table v-if="false" :data="room.records" border element-loading-text="拼命加载中" height="calc(100% - 45px)" ref="mainTable" size="mini" v-loading="loading" class="mainTable" @selection-change="handleSelectionChange">
      <el-table-column type="selection" :selectable="(row) => !!row.file" width="55" />
      <el-table-column label="#" show-overflow-tooltip type="index" width="50" />
      <el-table-column label="分析视频" prop="name" show-overflow-tooltip width="140" />
      <el-table-column label="视频时间点" prop="time" show-overflow-tooltip width="140" />
      <!-- <el-table-column label="创建时间" prop="createTime" show-overflow-tooltip width="140"></el-table-column> -->
      <el-table-column label="机械间图片地址" min-width="140" prop="file" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-button @click="lookItem(scope.row)" type="text">{{ scope.row.file }}</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
// import { Handle } from '@/store/modules/handle/mixins'
import convert from '@/utils/convert';
// import { BatchFile } from '@/facade/download'
export default {
  data() {
    return {
      loading: false,
      tableData: [],
      selectionList: [],
      batchFile: ''
    };
  },
  props: {
    lkjId: {
      type: String,
      default: ''
    }
  },
  methods: {
    lookItem(row) {
      this.$emit('look-item', row);
    },
    download() {
      if (this.selectionList.length <= 0) {
        this.$message.warning('请选择要下载的数据！');
        return false;
      }
      const params = this.selectionList.map(item => {
        return {
          name: `${item.name}-${item.time}`,
          url: item.file,
          suffix: 'jpg'
        };
      });
      this.batchFile.addBatch(params);
    },
    handleSelectionChange(val) {
      this.selectionList = val;
    }
  }
};
</script>

<style scoped>
.mainTable {
  height: 100% !important;
  overflow-y: scroll;
}
.download-all {
  margin-left: 10px;
  font-size: 12px;
  text-decoration: underline;
  color: #0091ff;
  cursor: pointer;
}
.download-all:hover {
  color: #11a2ff;
}
.img-list-wrap {
  padding: 10px 16px;
}
.img-list-wrap .img-list-item {
  width: 223px;
  box-sizing: border-box;
  cursor: pointer;
  float: left;
  margin-bottom: 15px;
  margin-right: 15px;
}
.img-list-wrap .img-list-item .video-path {
  padding: 10px;
  line-height: 16px;
  font-size: 12px;
  color: #323232;
  background: #e5e5e5;
  word-break: break-all;
}
.img-list-wrap .img-list-item .img-wrap {
  width: 223px;
  height: 126px;
  background: #000;
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
}
.img-list-wrap .img-list-item .img-wrap img {
  vertical-align: middle;
  width: 100%;
  height: 100%;
  transition: all 0.2s;
}
.img-list-wrap .img-list-item .img-wrap p {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  line-height: 26px;
  font-size: 12px;
  padding-left: 10px;
  color: #fff;
}
.img-list-wrap .img-list-item:hover .video-path {
  color: #fff;
  background: #0091ff;
}
.img-list-wrap .img-list-item:hover .img-wrap {
  border: 1px solid #0091ff;
}
.img-list-wrap .img-list-item:hover .img-wrap img {
  transform: scale(1.2);
  transform-origin: center;
}
.no-data {
  height: 200px;
  border: 1px solid #eee;
  line-height: 200px;
  text-align: center;
  margin: 10px 16px 0;
  font-size: 14px;
}
</style>
